// 封装 上传文件
const multer  = require('multer')
const path = require('path');
// 自定义上传目录 文件名
const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, './public/uploads')
  },
  filename: function (req, file, cb) {

    cb(null, file.fieldname + '-' + Date.now()+path.extname(file.originalname))
  }
})

const upload = multer({ storage: storage });

module.exports = upload;